function [model, infos] = tr_matrix_completion_comparison(data_ts, data_ls, model, params)
% [model, infos] = tr_matrix_completion(data_ts, data_ls, model, params)
%
% We obtain a local minimum (or a stationary point) of the non-convex problem
% minimize f(U, B, V) + \lambda Trace(B). 
% The search space is the quotietnt space. Details in the 
% "Low-rank optimization with trace norm penalty"
% Technical report (arXiv 1112.2318), 2011.
%
%
% The optimization algorithm is trust-region.
%
%
% Parameters
%
%   data_ls.rows               vector containing first indices of the points
%   data_ls.cols               vector containing second indices of the points
%   data_ls.entries            vector of known entries
%   data_ts                    structure array for testing (if not empty)
%   (model.U,model.B,model.V)  initial point
%   params                     structure array containing algorithm parameters
%                              (see default_arams for details)
%
%
% Output
%
%   model        structure array of the final point of rank model.p 
%   preds_ts     prediction for testing (computed only if data_ts is not empty)
%   infos        structure array with additional information
%
%
% Authors:
% Bamdev Mishra <b.mishra@ulg.ac.be>  

    fun_set=@functions_nsym_polar_geometry; % Manifold related descriptions
    fun_obj=@functions_matrix_completion_polar; % Problem related ingredients
    
    if ~isfield(model, 'sparse_structure'),
        warning('WarnTests:convertTest',...
            'You did not supply the "sparse_structure" field in "model".\nCreating a sparse skeleton, "model.sparse_structure" for efficiency.\n');
        sparse_structure = sparse(data_ls.rows,data_ls.cols,data_ls.entries,model.d1,model.d2);
        model.sparse_structure = sparse_structure;  % creating a field
    end
    
    if ~isfield(model, 'sparse_structure2'),
        warning('WarnTests:convertTest',...
            'You did not supply the "sparse_structure2" field in "model".\nCreating a sparse skeleton, "model.sparse_structure2" for efficiency.\n');
        sparse_structure2 = sparse(data_ls.rows,data_ls.cols,data_ls.entries,model.d1,model.d2);
        model.sparse_structure2 = sparse_structure2; % creating a field
    end
    
    params.data_ts = data_ts; % Test entries when aksed to compute predictions for each iteration

    [model, infos] = trust_region_comparison(fun_set, fun_obj, data_ls, model, params);
    
    
end
